auto();
var time = new Date().valueOf();
var 图集=new Array()
 图集[0]=images.read("/sdcard/脚本/图片/安装领取.jpg")
 图集[1]=images.read("/sdcard/脚本/图片/点击领取.jpg")
 图集[2]=images.read("/sdcard/脚本/图片/狠心放弃.jpg")
 图集[3]=images.read("/sdcard/脚本/图片/直接领取.jpg")
 图集[4]=images.read("/sdcard/脚本/图片/蓝水壶.jpg")
 图集[5]=images.read("/sdcard/脚本/图片/关闭兑奖.jpg")
 图集[6]=images.read("/sdcard/脚本/图片/继续种花.jpg")
 图集[7]=images.read("/sdcard/脚本/图片/开心收下.jpg")
 图集[8]=images.read("/sdcard/脚本/图片/去浇水.jpg")
 图集[9]=images.read("/sdcard/脚本/图片/立即领取.jpg")
  图集[10]=images.read("/sdcard/脚本/图片/金水壶.jpg")
  图集[11]=images.read("/sdcard/脚本/图片/知道了.jpg")
  图集[12]=images.read("/sdcard/脚本/图片/华农太忙.jpg")
var thread1 =threads.start(function () {

    while (true) {

        click("立即开始")


        sleep(500)
    }
});
if(!requestScreenCapture()){
    toast("请求截图失败");
    exit();
}
thread1.interrupt()
app.startActivity({
    action: "android.intent.action.VIEW",
    data: 'hiapp://com.huawei.appmarket?activityName=activityUri|webview.activity&params={"params":[{"name":"url","type":"String","value":"' + encodeURIComponent("https://uowap.hicloud.com/appdl-uomp-cn/campaignpreview/af8e7e9a-c3be-4463-83e2-1f6d94f980d3/index.html?page=campaign&productId=&campaignId=46929&shareId=463783639952396032&shareTo=weixin&shareFrom=appmarket#/") + '"},{"name":"uri","type":"String","value":"external_webview"}]}&channelId=',
    packageName: "com.huawei.appmarket"
});
var img = captureScreen();
while (1) {
    
   
    //关闭签到框
    找色("#fffffd",[[-17,171,"#fb776a"],[-107,209,"#f9f1e6"],[21,214,"#f9f0e7"],[218,1069,"#7feee5"],[307,992,"#f42d26"]],"关闭签到框");
    click("邀请送花瓣");
    click("立即领取");
    let img = captureScreen();
    //关闭明日可领
    var p = images.findMultiColors(img, "#ffffff",[[-50,175,"#783000"],[171,192,"#773100"],[-178,925,"#a2a2a2"],[-10,917,"#a4a4a4"],[194,929,"#a0a0a0"],[-56,945,"#ffffff"],[-9,949,"#ffffff"],[30,949,"#ffffff"]]);
    if (p) {
        log("关闭明日可领");
        click(p.x, p.y)
        sleep(3000)
        break;
    }
   //开心收下
  找色("#fdb522",[[-2,-13,"#ffffff"],[0,14,"#feebc9"],[-53,-1,"#ffffff"],[82,-3,"#ffffff"],[47,-6,"#fdba25"],[38,7,"#fdb01e"],[1,-11,"#ffffff"]],"开心收下");
  


}
console.log("已完成邀请");


while (1) {
    let img = captureScreen();
    var p = images.findMultiColors(img, "#fac60d", [[49, -46, "#e2e9f4"], [5, -86, "#e2e9f4"], [-25, -7, "#fac60d"], [-50, 46, "#ecaf09"], [-24, 2, "#fac60d"]]);
    if (p) {
        console.log(p);
        sleep(1000)
        click(p.x, p.y);
        break
    }
    sleep(500)
}
console.log("已点击去采蜜");
while (1) {
    sleep(10);
    click("开始采蜜")
    click("拆水滴大礼包");
    click("继续免费挑战");
    let img = captureScreen();
    var p = images.findMultiColors(img, "#ff7e14", [[-64, 87, "#5c8306"], [83, 113, "#ffe577"], [16, 249, "#68290d"], [77, 191, "#2b5400"]], {
        region: [366, 1630, 350, 200]
    });
    if (p) {
        log(p);
        click(871, 2161)
    }
    p = images.findMultiColors(img, "#ffffff", [[55, -47, "#923925"], [99, 27, "#8a3427"], [-16, 91, "#fab234"], [57, 201, "#bb5525"]], {
        region: [366, 1630, 350, 200]
    });
    if (p) {
        log(p);
        click(195, 2200)
    }
    if (text("明日再来").findOne(20)) {
        back()
        break;
    }
}
console.log("已采蜜");

while (1) {
    var 去领取 = textContains("去领取").findOne(100)
    if (去领取) {
        sleep(1000)
        click("去领取")
    }
    var 去消费 = textContains("去领取").findOne(100)
    if (去消费) {
        break;
    }
    click("立即领取")
    var img = captureScreen();
     找图(图集,img)
/*
    //点击领取50g水滴
找色("#f1cc7e",[[-51,5,"#fdb11f"],[-34,4,"#ffe198"],[-95,-31,"#fdcc31"],[-51,-302,"#ffffff"],[57,-355,"#fc5b6a"],[-292,-552,"#fcbf05"],[204,-544,"#edecf1"],[159,-795,"#040404"]],"点击领取50g水滴");
//点击领取100g水滴
找色("#fec32b",[[-12,48,"#fca216"],[-214,45,"#fba417"],[-207,-16,"#ffce33"],[-354,-308,"#e54d76"],[99,-315,"#e63873"],[-215,-216,"#ed5c6d"],[-395,-540,"#fee205"],[160,-524,"#e9e8ed"],[-309,-740,"#8acae6"],[-131,-793,"#5e8508"],[-141,-846,"#ffb60b"]],"点击领取100g水滴");

   //领取100花瓣
找色("#f2b536",[[15,3,"#eab44a"],[66,-1,"#fffff4"],[285,-247,"#e03875"],[-263,-254,"#e44d78"],[-279,-569,"#fee205"],[284,-560,"#e9e8ed"],[-65,-641,"#74990d"]],"领取100花瓣");
//领取30g水滴+2花瓣
找色("#fffff3",[[4,9,"#fdb320"],[61,4,"#ffe9b0"],[150,7,"#fdb522"],[98,43,"#fca115"],[35,-285,"#fefefe"],[66,-785,"#94c222"],[-250,-561,"#ffe304"],[-156,-745,"#a0ddf2"]],"领取30g水滴+2花瓣");
//关闭花瓣兑换弹窗
找色("#eff3f6",[[6,-20,"#5e696f"],[21,2,"#5e696f"],[-17,-1,"#5e696f"],[-345,278,"#e62601"],[-333,457,"#eb8f00"],[-318,617,"#fecb32"],[-44,489,"#ffffff"]],"关闭花瓣兑换弹窗");

  //继续种花
  找色("#fffff3",[[19,7,"#ffffff"],[-14,2,"#feb421"],[36,5,"#fcb21f"],[-54,-384,"#ea4273"],[-430,-374,"#e75177"],[-96,-502,"#f8c140"]],"继续种花");

   
  //开心收下
 找色("#fdb522",[[-2,-13,"#ffffff"],[0,14,"#feebc9"],[-53,-1,"#ffffff"],[82,-3,"#ffffff"],[47,-6,"#fdba25"],[38,7,"#fdb01e"],[1,-11,"#ffffff"]],"开心收下");
 
  
   
    //安装领取
    找色( "#fffffd",[[-46,3,"#fffff6"],[77,0,"#ffffff"],[58,-5,"#fcb922"],[9,2,"#f9b428"],[0,-326,"#58e3e0"],[38,-442,"#005dc7"],[246,-279,"#fff0db"]],"安装领取");
    
    
    //第二个安装领取
   找色("#fdb11f",[[-26,1,"#ffffff"],[-76,0,"#ffffff"],[60,-5,"#ffffff"],[132,-7,"#fdb622"],[-171,-1,"#fdb11f"],[-31,-38,"#fecd32"],[39,-380,"#ffffff"],[-33,-347,"#4dbaf4"]],"第二个安装领取");
    */
   var img = captureScreen();
    //浇水按钮
   var p = images.findMultiColors(img, "#eaff83",[[9,-16,"#2067f3"],[-13,16,"#2067f3"],[-20,-29,"#2dcdff"],[19,30,"#29ccff"]]);//蓝水湖
    if (p) {
        log("蓝色浇水按钮");
        click(p.x, p.y)
    }
    p=images.findMultiColors(img, "#ff6000",[[10,-13,"#fae621"],[-22,-11,"#fae621"],[-56,3,"#ee7800"],[-15,42,"#ffad54"],[-67,98,"#0f9fb2"]]);//金水湖
     if(p){
        log("金色浇水按钮");
        click(p.x, p.y)
    }
 //恭喜您获得大水壶奖励 去浇水
    找色("#ffffff", [[-50, -4, "#ffffff"], [43, 5, "#ffffff"], [-155, 12, "#fdae1d"], [188, 19, "#fca91a"], [-3, -34, "#ffd034"], [12, 45, "#fca01b"], [47, -552, "#ff6000"], [82, -530, "#fae621"]],"下应用领水滴去浇水");
  //知道了
  找色("#fdb522",[[-30,-14,"#ffffff"],[26,-15,"#ffffff"],[63,-3,"#ffffff"],[111,11,"#fdad1c"],[-132,11,"#fdad1c"],[9,-384,"#ffcb35"],[-1,-291,"#ff8417"],[212,-268,"#ffeac5"]],"知道了");
   /*

    //点击领取100g水滴+2花瓣
    找色( "#ffffff", [[-14, 1, "#ffffff"], [-6, 1, "#fdb723"], [-136, 0, "#ffffff"], [160, -10, "#ffffff"], [28, -306, "#ffffff"], [-206, -555, "#fcd604"], [-48, -576, "#668c09"]],"点击领取100g水滴+2花瓣");
   
   
    //下应用领水滴去浇水
    找色("#ffffff",[[-51,-5,"#ffffff"],[39,-1,"#ffffff"],[-129,8,"#fdb01e"],[177,25,"#fca518"],[2,-482,"#56c3f7"],[44,-549,"#feffff"]],"下应用领水滴去浇水");
   
    //安装领取
    找色( "#fdc13f",[[-8,10,"#fdb01e"],[-20,-5,"#fdbc26"],[-38,-5,"#ffffff"],[-58,-30,"#fece33"],[-32,-397,"#50bdf4"],[18,-481,"#ffffff"]],"安装领取");
    
    //关闭下应用去浇水
    找色("#ffffff",[[-10,618,"#005fc9"],[-61,691,"#7aeee1"],[-51,1154,"#ffffff"],[-1,1160,"#ffffff"],[74,1173,"#fdb01e"],[15,1167,"#fdb421"],[-34,1157,"#fdbc26"]],"关闭下应用去浇水");
    
    
    //关闭下应用去浇水2
   找色( "#ffffff",[[-4,503,"#54cbfa"],[40,595,"#feffff"],[-76,688,"#2196ec"],[-51,1165,"#ffffff"],[-28,1159,"#fdb924"],[-2,1169,"#fdb21f"],[20,1168,"#fdb320"],[4,1178,"#ffffff"]],"关闭下应用去浇水2");
  
*/
}
threads.shutDownAll()
卸载app1()
function 找色(颜色,各坐标颜色,日志){
    var img = captureScreen();
    var p = images.findMultiColors(img, 颜色,各坐标颜色)
    if(p){
        sleep (1000)
          console.log(日志);
        click(p.x, p.y);
        sleep(1000)
    }
      
    
}
function 卸载app1() {
    //sleep(30000);
    log("开始卸载");
    var pm = context.getPackageManager()
    var appList = pm.getInstalledApplications(0)

    for (let i = 0; i < appList.size(); i++) {
        var app_ = appList.get(i)
        var appInfo = {
            appName: app_.loadLabel(pm),
            packageName: app_.packageName,
            isSystemApp: app_.isSystemApp(),
            lastUpdateTime: pm.getPackageInfo(app_.packageName, 0).lastUpdateTime
        }
        if (appInfo.lastUpdateTime > time) {
            console.log(appInfo.appName + "卸载中");
            app.uninstall(appInfo.packageName);
            sleep(1000)
            while (!click("卸载"));
        }
    }



    sleep(15000);
    log("卸载完成");

}

function 找图(图集,截图){
for(var i=0;i<图集.length;i++){
var p = findImage(截图,图集[i]);
if(p){
    log(p)
   var x=p.x*1+图集[i].getWidth()/2
   var y=p.y*1+图集[i].getWidth()/2
   log(图集[i].getWidth()/2,图集[i].getWidth()/2)
   click(x,y)
}

}


}